<template>
<el-dialog
    :title="title"
    :visible="visible"
    width="630px"
    :before-close="beforeClose"
    :modal="false"
  >
    <slot :rules="rules"></slot>
    <div slot="footer" class="dialog-footer" v-if="type !== 'preview'">
      <el-button @click="beforeClose" class="cancel">取消</el-button>
      <el-button type="primary" @click="$emit('submit')">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      required: true
    },
    totalList: {
      type: Array,
      required: true
    },
    regionForm: {
      type: Object,
      required: true
    },
    type: {
      type: String,
      required: true
    },
    rules: {
      type: Object
    }
  },
  data () {
    return {

    }
  },
  computed: {
    title () {
      let text = null
      if (this.type === 'preview') {
        text = '区域详情'
      } else if (this.type === 'add') {
        text = '新增区域'
      } else if (this.type === 'edit') {
        text = '修改区域'
      }
      return text
    }
  },
  methods: {
    beforeClose () {
      this.$emit('beforeClose')
    }
  }
}

</script>

<style>

</style>
